package taskinstance;

/**
 * @author ryan Task factory to create different type of task.
 * 
 *         Task type: 1. Instant task: the task will run immediately. 2. Timing task: the task will
 *         run until the time. 3. Period task: the task will run period according to the time cycle.
 *         4.
 */
public class TaskFactory {
  public static Task createTask(TaskType type, String sourceIp, String targetIp, String urlSource,
      boolean osreEncapsulation, boolean encryption) {
    // do
    if (type == TaskType.INSTANT_TASK) {
      return new InstantTask(sourceIp, targetIp, urlSource, osreEncapsulation, encryption);
    } else if (type == TaskType.INTERMEDIATE_TASK) {
      return new IntermediateTask(sourceIp, targetIp, urlSource);
    }
    return new Task(); // shouldn't reach here.
  }

  public static Task createTask(TaskType type, String sourceIp, String targetIp, String urlSource,
      String otherAttribute, boolean osreEncapsulation, boolean encryption) {
    // do
    switch (type) {
      case TIMING_TASK:
        return new TimingTask(sourceIp, targetIp, urlSource, otherAttribute, osreEncapsulation,
            encryption);
      case PERIOD_TASK:
        return new PeriodTask(sourceIp, targetIp, urlSource, otherAttribute, osreEncapsulation,
            encryption);
      default:
        return new Task(); // shouldn't reach here.
    }
  }

}
